using UnityEngine;

[ExecuteInEditMode]
public class lookcamui : MonoBehaviour
{
	public Transform m_tras;

	public Transform target;

	public UIPanel panel;

	private float mag;

	private Vector3 dir;

	private void Start()
	{
		m_tras = base.transform;
	}

	private void Update()
	{
		if (target != null)
		{
			dir = target.position - m_tras.position;
			mag = dir.magnitude;
			if (mag > 0.001f)
			{
				Quaternion rotation = Quaternion.LookRotation(-dir);
				m_tras.rotation = rotation;
			}
			if (panel.depth != panelnum())
			{
				panel.depth = panelnum();
			}
		}
	}

	public int panelnum()
	{
		if (mag < 2.1f)
		{
			return 5;
		}
		if (mag < 3f)
		{
			return 4;
		}
		if (mag < 4f)
		{
			return 3;
		}
		return 2;
	}
}
